package com.xiao.train.${module}.controller.admin;

import com.xiao.train.${module}.service.${Domain}Service;
import com.xiao.train.common.resp.CommonResp;
import com.xiao.train.${module}.req.${Domain}QueryReq;
import com.xiao.train.${module}.req.${Domain}SaveReq;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/${do_main}")
public class ${Domain}AdminController {

    @Autowired
    ${Domain}Service ${domain}Service;

    @PostMapping("save")
    public CommonResp save(@Valid @RequestBody ${Domain}SaveReq req) {
        ${domain}Service.save(req);
        return new CommonResp();
    }

    @GetMapping("query-list")
    public CommonResp queryList(@Valid ${Domain}QueryReq req) {
        return new CommonResp(${domain}Service.queryList(req));
    }

    @DeleteMapping("delete/{id}")
    public CommonResp delete(@PathVariable Long id) {
        ${domain}Service.delete(id);
        return new CommonResp();
    }
}